package com.example.qxfw.rcyw.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.qxfw.common.entity.yj.DisWeatherMoniInfo;
import com.example.qxfw.rcyw.mapper.DisWeatherMoniInfoMapper;
import com.example.qxfw.rcyw.service.DisWeatherMoniInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class DisWeatherMoniInfoServiceImpl implements DisWeatherMoniInfoService {

    @Autowired
    private DisWeatherMoniInfoMapper disWeatherMoniInfoMapper;


    @Override
    public List<DisWeatherMoniInfo> getMonitorDisWeather() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        Timestamp startTime = Timestamp.valueOf(sdf.format(date)+" 00:00:00");
        Timestamp endTime = Timestamp.valueOf(sdf.format(date)+" 23:59:59");
        LambdaQueryWrapper<DisWeatherMoniInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.between(DisWeatherMoniInfo::getMoni_time,startTime,endTime).orderByDesc(DisWeatherMoniInfo::getMoni_time);
        List<DisWeatherMoniInfo> disWeatherMoniInfos = disWeatherMoniInfoMapper.selectList(queryWrapper);
        return disWeatherMoniInfos;
    }
}
